package io.renren.modules.peoplemanage.controller;

import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import io.renren.modules.peoplemanage.entity.SysStudentEntity;
import io.renren.modules.peoplemanage.service.SysStudentService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;


/**
 *
 *
 * @author kiven
 * @email 2213593288@qq.com
 * @date 2020-09-04 16:50:44
 */
@RestController
@RequestMapping("/sys/student")
public class SysStudentController {
    @Autowired
    private SysStudentService sysStudentService;

    /**
     * 列表
     */
    @PostMapping("/list")
    @RequiresPermissions("sys:student:list")
    public R list(@RequestBody Map<String, Object> params){

        PageUtils page = sysStudentService.getStudentList(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{studentId}")
    @RequiresPermissions("generator:sysstudent:info")
    public R info(@PathVariable("studentId") Integer studentId){
		SysStudentEntity sysStudent = sysStudentService.getById(studentId);

        return R.ok().put("sysStudent", sysStudent);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("generator:sysstudent:save")
    public R save(@RequestBody SysStudentEntity sysStudent){
		sysStudentService.save(sysStudent);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("generator:sysstudent:update")
    public R update(@RequestBody SysStudentEntity sysStudent){
		sysStudentService.updateById(sysStudent);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("generator:sysstudent:delete")
    public R delete(@RequestBody Integer[] studentIds){
		sysStudentService.removeByIds(Arrays.asList(studentIds));

        return R.ok();
    }

}
